#!/bin/bash

#rhost=$1
#rlogin=$2
#rpasswd=$3
#dbnmame=$4
#dblogin=$5
#dbpassword=$6
#archivepassword=$7
productionday=$8

print_usage()
{
    echo "Usage: $0 <rhost> <rlogin> <rpasswd> <dbname> <dblogin> <dbpassword> <archivepassword> [<production day> ...]"
    echo "Download the production data of the given day."
}

if [ "x$productionday" == "x" ]; then
   echo "[ERROR] All arguments not available."
   print_usage
   exit 1
fi

#/data/scripts/retrieve_data_huizhou_ns.pl -log /tmp/retrieve_data_huizhou_ns.log $rhost $rlogin $rpasswd $dbnmame $dblogin $dbpassword $archivepassword $productionday
/data/scripts/retrieve_data_tct-huizhou_ns.pl -log /data/home/simgen/retrieve_data_tct-huizhou_ns.log $@
error=`grep "\[ERROR\]" /tmp/retrieve_data_huizhou_ns.log`
res=$?
if [ $res -eq 0 ]; then
    /data/scripts/sendmail.pl -f multisimgen.support@tcl.com -t frederic.chailloux@jrdcom.com -s "Multisimgen >retrieve_data_tct-huizhou_ns.sh< notification" /tmp/retrieve_data_tct-huizhou_ns.log
fi
